package cc.ls51.cms.controller;

import cc.ls51.cms.BO.TbFtpAnalyzeBO;
import cc.ls51.cms.shiro.ShiroUtils;
import cc.ls51.cms.utils.RenderUtil;
import cc.ls51.common.PageUtils;
import cc.ls51.form.UserListForm;
import cc.ls51.modules.FtpAnalyze.entity.TbFtpAnalyze;
import cc.ls51.modules.SysUser.entity.SysUser;
import cc.ls51.modules.SysUser.service.ISysUserService;
import cc.ls51.vo.ResultObject;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author llf
 * @since 2019-08-27
 */
@Controller
@RequestMapping("/Tools")
public class ToolsController {
    Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    ISysUserService sysUserService;
    @Autowired
    RenderUtil renderUtil;

    @GetMapping(value = "/NXSProfit")
    public String userList(UserListForm form, Model model) {
        return "/Tools/NXSProfit";
    }

    @RequestMapping(value = "/uploadExcel")
    public String uploadExcel(@RequestParam("file")MultipartFile file) {
        ImportParams importParams = new ImportParams();
        importParams.setHeadRows(7);
        importParams.setTitleRows(21);
        
        importParams.setImportFields(new String[]{"xls"});
        List<TbFtpAnalyzeBO> list = null;
        try {
            list = ExcelImportUtil.importExcel(file.getInputStream(), TbFtpAnalyzeBO.class, importParams);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/Tools/NXSProfit";
    }
    @RequestMapping(value = "/exportExcel")
    public String exportExcel(Model model, String v) {
        return "/Tools/NXSProfit";
    }
}
